package com.concurrency.example.blockQueue;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.LinkedBlockingDeque;

/**
 * 阻塞队列
 * @Auther: xuwei
 * @Date: 2018/11/29 16:30
 */
public class Test {
    private final static BlockingDeque<File> fileQueue = new LinkedBlockingDeque<>();

    private final static List<String> index = new CopyOnWriteArrayList<>();

    public static void main(String[] args) throws InterruptedException{

        File file = new File("D:\\");

        new Thread( new FileCrawler(fileQueue, null, file)).start();
        new Thread( new Indexer(fileQueue, index)).start();

        for (int i = 0; i < 10; i++) {
            Thread.sleep(10);
            System.out.println(index);
        }


    }
}
